<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <!-- 个人信息添加表单 -->
    <div class="personal-info">
        <h2>添加个人信息</h2>
        <form id="personalInfoForm">
            <div class="form-group">
                <label for="name">姓名：</label>
                <input type="text" id="name" required>
            </div>
            <div class="form-group">
                <label for="age">年龄：</label>
                <input type="number" id="age" required>
            </div>
            <div class="form-group">
                <label for="email">邮箱：</label>
                <input type="email" id="email" required>
            </div>
            <div class="form-group">
                <label for="phone">手机号码：</label>
                <input type="tel" id="phone" required>
            </div>
            <div class="form-group">
                <label for="sex">性别：</label>
                <select id="sex" required>
                <option value="0">男</option>
                <option value="1">女</option>
            </select>
            </div>
            <button type="button" onclick="addPersonalInfo()">提交</button>
        </form>
    </div>
</body>
<script>
    // 添加个人信息
    function addPersonalInfo() {
        // 获取用户输入的个人信息
        var name = document.getElementById('name').value;
        var age = document.getElementById('age').value;
        var email = document.getElementById('email').value;
        var phone = document.getElementById('phone').value;
        var sex = document.getElementById('sex').value;

        $.ajax({
            type: "post",
            url: `http://47.94.4.201/index.php/index/index/mycenter`,
            dataType: "json",
            data: {
                name: name,
                age: age,
                email: email,
                phone: phone,
                sex: sex
            },
            success: function(data) {
                console.log(data);

            },
            error: function(e) {
                console.log(e);
                alert(e);
            }
        });



    }
</script>

</html>